package org.ko.core.domain.support;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.apache.commons.lang3.builder.CompareToBuilder;


/**
 * Entity - 排序基类
 * 
 * @author ByTheWay
 * @version 1.0.0
 */
@MappedSuperclass
public abstract class OrderEntity extends BaseEntity implements Comparable<OrderEntity> {
	private static final long serialVersionUID = -3308824901062701268L;

	/** "排序"属性名称 */
	public static final String ORDER_PROPERTY_NAME = "orderNo";

	/** 排序 */
	private int orderNo;

	/**
	 * 获取排序
	 * @return 排序
	 */
	@Column(name = "orderNo")
	public int getOrderNo() {
		return orderNo;
	}

	/**
	 * 设置排序
	 * @param orderNo
	 *            排序
	 */
	public void setOrderNo(int order) {
		this.orderNo = order;
	}

	/**
	 * 实现compareTo方法
	 * @param orderEntity
	 *            排序对象
	 * @return 比较结果
	 */
	public int compareTo(OrderEntity orderEntity) {
		return new CompareToBuilder().append(getOrderNo(), orderEntity.getOrderNo()).append(getId(), orderEntity.getId()).toComparison();
	}

}